package com.bfxy.rabbit.api;

import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @describte:MQ发送的消息实体
 * @program:rabbit-parent
 * @author:zhengdp
 * @create:2021-09-14 20:37:57
 **/
@Data
public class Message implements Serializable {


    private static final long serialVersionUID = 841277940410721237L;

    /**
     * 消息的唯一ID
     */
    private String messageId;

    /**
     *  将Exchange的类型固定为Topic （消息的主题）
     *   这边将类型写死了
     */
    private String topic;

    /* 消息的路由规则 */
    private String routingKey = "";

    /*  额外属性 （消息的附加属性） */
    private Map<String,Object> attributes = new HashMap<>();

    /* 延迟消息的参数配置 */
    private int delayMills;

    /**
     * 消息的类型： 默认为CONFIRM消息
     *  迅速消息
     *  延迟消息
     *  可靠消息
     */
    private String messageType = MessageType.CONFIRM;

    public Message() {
    }

    public Message(String messageId, String topic,
                   String routingKey, Map<String, Object> attributes,
                   int delayMills, String messageType) {
        this.messageId = messageId;
        this.topic = topic;
        this.routingKey = routingKey;
        this.attributes = attributes;
        this.delayMills = delayMills;
        this.messageType = messageType;
    }

    public Message(String messageId, String topic,
                   String routingKey, Map<String, Object> attributes,
                   int delayMills) {
        this.messageId = messageId;
        this.topic = topic;
        this.routingKey = routingKey;
        this.attributes = attributes;
        this.delayMills = delayMills;
    }
}
